import axios from 'axios';

const http = axios.create({
    baseURL: 'http://localhost:8090', // 假设后端服务运行在 3000 端口
    timeout: 5000,
});

// 添加请求拦截器
http.interceptors.request.use(
    config => {
        const token = localStorage.getItem('token');
        if (token) {
            config.headers.Authorization = `Bearer ${token}`;
        }
        return config;
    },
    error => {
        return Promise.reject(error);
    }
);

export default http;